local M = {}

M.append = function(tb,el)
   table.insert(tb, el)
end

M.contains = function(tb,el)
    return vim.tbl_contains(tb, el)
end

M.filter = function(tb,callback)
  return vim.tbl_filter(function(el)
    return callback(el) -- false to exclude
  end, tb)
end

M.map = function(tb,callback)
    return vim.tbl_map(callback,tb)
end

-- index-value
M.foreach = function(tb,callback)
    for index, el in ipairs(tb) do
        callback(el,index)
    end
end

-- key-value
-- example:
-- local icons = {
--   Error = "",
--   Warn = "",
--   Info = "",
--   Hint = "󰌵 ",
-- }
M.forkey = function(tb,callback)
    for k, el in pairs(tb) do
        callback(k,el)
    end
end

return M
-- EOP
